package xiao.ke.serviceinvoker1.filter;/**
 * @author XuXiaoK
 * @create 2020-01-21 21:55
 */

import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 *@Author XiaoKe
 *@Date 2020/1/21 21:55
 *@Description TODO
 */
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
/**
 * urlPatterns:拦截所有路径(拦截规则)
 * filterName:过滤器名称
 */
//@WebFilter(urlPatterns = "/*", filterName = "hystrixFilter")
//public class HystrixFilter implements Filter{
//    public void destroy() { }
//
//    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
//            throws IOException, ServletException {
//        // 初始化Hystrix上下文
//        HystrixRequestContext ctx = HystrixRequestContext.initializeContext();
//        try {
//            chain.doFilter(request, response);
//        } catch (Exception e) {
//
//        } finally {
//            ctx.shutdown();
//        }
//    }
//    public void init(FilterConfig arg0) throws ServletException { }
//}
